<?php
include_once("tpl.php");
$main = htmlBody();
echo tpl($main);
?>
<?php
function htmlBody()	{
	include_once("inc/checkArg.php");
	$mod = checkArg("mod","twoball");
	include_once("inc/xml2mod.php");
	$aModList = xml2mod('lotteryMod/mod.xml');
	$sHtml = "";
	foreach($aModList as $aMod)	{
		if(file_exists("history/".$aMod["file"].".csv"))	{
			include_once("inc/mod2ahref.php");
			$sHtml.= mod2ahref($aMod,"stat.php");
		}
		$sHtml.=" ";
	}
	$sHtml.= "<hr />";
	foreach($aModList as $aMod)	{
		if(strcmp($aMod["file"],$mod)==0)	{
			$sHtml.= $aMod["name"]."<br />";
			$sHtml.=csv2stat($mod);
		}
	}
	return $sHtml;
}
?>
<?php
function csv2stat($mod)	{
	$sMod	=	$mod;
	include_once("inc/file2history.php");
	$aHistory	=	file2history("history/".$sMod.".csv");
	include_once("inc/lotteryMod.php");
	$aMod		=	lotteryMod("lotteryMod/".$sMod.".csv");
	include_once("inc/history2stat.php");
	$strTable	=	history2stat($aHistory,$aMod);
	return $strTable;	
}
?>